package com.liujun.spring4.demo.aop.iocset.beanscope.postconstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * 进行数据的完整操作
 *
 * @author liujun
 * @version 1.0
 * @date 2018-08-20 10:31:00
 */
@Component
public class Boss {

  private Car car;

  public Boss() {
    System.out.println("exec boss constructor  function");
  }

  @Autowired
  public void setCar(Car car) {
    System.out.println("execute Autowired in setCar");
    this.car = car;
  }

  /** 相当于init-method属性所指定的方法 */
  @PostConstruct
  public void init1() {
    System.out.println("execute PostConstruct in init1 ");
  }

  @PostConstruct
  public void init2() {
    System.out.println("execute PostConstruct in init2");
  }

  /** 相当于destory-method属性指定的方法，即销毁方法 */
  @PreDestroy
  public void destory1() {
    System.out.println("execute PreDestroy  in destory1");
  }

  @PreDestroy
  public void destory2() {
    System.out.println("execute PreDestroy in destory2");
  }
}
